package com.ruoyi.project.system.sample.controller;

import java.util.List;

import com.ruoyi.project.system.sample.domain.MySampleData;
import com.ruoyi.project.system.sample.service.IMySampleDataService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 做样详情信息Controller
 * 
 * @author cc
 * @date 2024-08-15
 */
@Controller
@RequestMapping("/system/sample/data")
public class MySampleDataController extends BaseController
{
    private String prefix = "system/sample/data";

    @Autowired
    private IMySampleDataService mySampleDataService;

    @RequiresPermissions("system:data:view")
    @GetMapping()
    public String data()
    {
        return prefix + "/data";
    }

    @GetMapping("/queryDevice")
    public String queryDevice()
    {
        return prefix + "/data";
    }
    /**
     * 查询做样详情信息列表
     */
    @RequiresPermissions("system:data:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MySampleData mySampleData)
    {
        startPage();
        List<MySampleData> list = mySampleDataService.selectMySampleDataList(mySampleData);
        return getDataTable(list);
    }

    /**
     * 导出做样详情信息列表
     */
    @RequiresPermissions("system:data:export")
    @Log(title = "做样详情信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MySampleData mySampleData)
    {
        List<MySampleData> list = mySampleDataService.selectMySampleDataList(mySampleData);
        ExcelUtil<MySampleData> util = new ExcelUtil<MySampleData>(MySampleData.class);
        return util.exportExcel(list, "做样详情信息数据");
    }

    /**
     * 新增做样详情信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存做样详情信息
     */
    @RequiresPermissions("system:data:add")
    @Log(title = "做样详情信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MySampleData mySampleData)
    {
        return toAjax(mySampleDataService.insertMySampleData(mySampleData));
    }

    /**
     * 修改做样详情信息
     */
    @RequiresPermissions("system:data:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        MySampleData mySampleData = mySampleDataService.selectMySampleDataById(id);
        mmap.put("mySampleData", mySampleData);
        return prefix + "/edit";
    }

    /**
     * 修改保存做样详情信息
     */
    @RequiresPermissions("system:data:edit")
    @Log(title = "做样详情信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MySampleData mySampleData)
    {
        return toAjax(mySampleDataService.updateMySampleData(mySampleData));
    }

    /**
     * 删除做样详情信息
     */
    @RequiresPermissions("system:data:remove")
    @Log(title = "做样详情信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(mySampleDataService.deleteMySampleDataByIds(ids));
    }
}
